package com.baoteng.rbspy.vo.response;

import java.util.Date;
import java.util.List;
import java.util.Optional;

import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.baoteng.rbspy.util.JsoupUtil;
import com.baoteng.rbspy.vo.JsonDateDeserializer;
import com.baoteng.rbspy.vo.JsonDateSerializer;
import com.baoteng.rbspy.vo.request.FileMissing;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.collect.Lists;

@JsonInclude(Include.NON_EMPTY)
public class HeResponse extends CommonResponse {

	String quoteNum;

	private String forceNum;

	private String busNum;

	/**
	 * 总支付金额
	 */
	Double sumPay;

	/**
	 * 只含商业、交强保费
	 */
	Double sumPremium;

	Double sumPayTax;

	private Double forFee;

	private Double busFee;

	private String ordCode;

	private List<FileMissing> missings;

	/**
	 * 交强险特约
	 */
	private List<SpcialPromise> forSpecialLists;

	/**
	 * 同步人保支付时间
	 */
	@JsonSerialize(using = JsonDateSerializer.class)
	@JsonDeserialize(using = JsonDateDeserializer.class)
	private Date payTime;
	
	/**
	 * 商业险特约
	 */
	private List<SpcialPromise> busSpecialLists;

	public HeResponse() {
		super();
	}

	public HeResponse(Integer businessStatus, String statusMessage) {
		setBusinessStatus(businessStatus);
		setStatusMessage(statusMessage);
	}

	public List<FileMissing> getMissings() {
		return missings;
	}

	public void setMissings(List<FileMissing> missings) {
		this.missings = missings;
	}

	public String getForceNum() {
		return forceNum;
	}

	public void setForceNum(String forceNum) {
		this.forceNum = forceNum;
	}

	public String getBusNum() {
		return busNum;
	}

	public void setBusNum(String busNum) {
		this.busNum = busNum;
	}

	public Double getForFee() {
		return forFee;
	}

	public void setForFee(Double forFee) {
		this.forFee = forFee;
	}

	public Double getBusFee() {
		return busFee;
	}

	public void setBusFee(Double busFee) {
		this.busFee = busFee;
	}

	public String getOrdCode() {
		return ordCode;
	}

	public void setOrdCode(String ordCode) {
		this.ordCode = ordCode;
	}

	public String getQuoteNum() {
		return quoteNum;
	}

	public void setQuoteNum(String quoteNum) {
		this.quoteNum = quoteNum;
	}

	public Double getSumPremium() {
		return sumPremium;
	}

	public void setSumPremium(Double sumPremium) {
		this.sumPremium = sumPremium;
	}

	public Double getSumPayTax() {
		return sumPayTax;
	}

	public void setSumPayTax(Double sumPayTax) {
		this.sumPayTax = sumPayTax;
	}

	public Double getSumPay() {
		return sumPay;
	}

	public void setSumPay(Double sumPay) {
		this.sumPay = sumPay;
	}

	public List<SpcialPromise> getForSpecialLists() {
		return forSpecialLists;
	}

	public void setForSpecialLists(List<SpcialPromise> forSpecialLists) {
		this.forSpecialLists = forSpecialLists;
	}

	public List<SpcialPromise> getBusSpecialLists() {
		return busSpecialLists;
	}

	public void setBusSpecialLists(List<SpcialPromise> busSpecialLists) {
		this.busSpecialLists = busSpecialLists;
	}

	public Date getPayTime() {
		return payTime;
	}

	public void setPayTime(Date payTime) {
		this.payTime = payTime;
	}

	public void parser(Element doc) {
		busSpecialLists = Optional.ofNullable(busSpecialLists).orElse(Lists.newArrayList());
		Element element = doc.getElementById("insertEngageRow_Data");
		if (element != null) {
			Elements elements = element.select("tbody>tr");
			elements.forEach(e -> {
				SpcialPromise clause = new SpcialPromise();
				JsoupUtil.newInstance().parse(e, clause);
				busSpecialLists.add(clause);
			});
		}
	}
}
